// 快速排序
function quickSort(arr) {
    if (arr.length <= 1) {
        return arr
    }
    let pivot = arr[0]
    let left = []
    let right = []
    for (let i = 1; i < arr.length; i++) {
        if (arr[i] < pivot) {
            left.push(arr[i])
        } else {
            right.push(arr[i])
        }
    }
    return quickSort(left).concat(pivot, quickSort(right))
}

let arr = [0, 2, 2, 1, 3, 4, 1]
console.log(quickSort(arr));